// pages/category/child/show-cates/show-cates.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    catesList: {
      type: Array,
      value: [],
      observer() {
        this.cpn_init();
      }
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    leftMenuList: [],
    rightMenuList: [],
    currentIndex: 0,
    backTop: 0,
  },
  /**
   * 组件的方法列表
   */
  methods: {
    cpn_init() {
      let leftMenuList = this.properties.catesList.map(item => {
        return {
          cat_name: item.cat_name,
          cat_id: item.cat_id
        }
      });
      let rightMenuList = this.properties.catesList.map(item => item.children);

      this.setData({
        leftMenuList,
        rightMenuList
      });
    },
    leftMenuClick(e) {
      let currentIndex = e.currentTarget.dataset.index;

      this.setData({
        currentIndex,
        backTop: 0
      })
    }
  },

})
